package com.ctsi.security.app.permissiontree;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Beans implements Serializable,Cloneable {

    private static final long serialVersionUID = -3381636278967838473L;
    private List<Item> item = new ArrayList<>();

    public void setItem(List<Item> item) {
        this.item = item;
    }

    public List<Item> getItem() {
        return item;
    }

    public Beans() {
    }

    public void addItem(String str){
        Item one = new Item();
        one.setTextContent(str);
        item.add(one);
    }
    @Override
    public Object clone() throws CloneNotSupportedException {
        Beans newBeans = (Beans) super.clone();
        List<Item> result = item.stream().map(item1 -> {
            Item m = null;
            try {
                 m = (Item) item1.clone();
            } catch (CloneNotSupportedException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
            return m;
        }).collect(Collectors.toList());
        newBeans.setItem(result);
        return newBeans;
    }
}
